package com.yj.gateway.config;

import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.GatewayCallbackManager;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

@Configuration
public class SentinelConfig {
    public SentinelConfig() {
        //设置sentinel限流和熔断后的处理方法
        GatewayCallbackManager.setBlockHandler((serverWebExchange, throwable)
                -> ServerResponse.ok().body(Mono.just("已限流或熔断！"), String.class));
    }
}

